﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Windows.Input;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238

namespace App9
{
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
            Loaded += MainPage_Loaded;
        }

    void MainPage_Loaded(object sender, RoutedEventArgs e)
    {
        var visual = MyRectangle.TransformToVisual(MyScrollViewer);
        var point = visual.TransformPoint(new Point(0, 0));

        // Windows 8.0
        MyScrollViewer.ScrollToVerticalOffset(point.Y);

        // Windows 8.1
        MyScrollViewer.ChangeView(null, point.Y, null);
    }
    }
}
